package com.bootcamp.jacase.lambda;

/**
 * @program: LambdaCode
 * @description:
 * @author: Keyu Li
 * @create: 2021-09-04 14:09
 **/

public class ComputeTool {

    public static void main(String[] args) {
//        calc(new Compute() {
//            @Override
//            public double compute(double a, double b) {
//                return 0;
//            }
//        }, 10, 20);
        calc((a,b)->a+b,1,2);
    }

    private ComputeTool() {
    }

    public static void calc(Compute C, double a, double b) {
//        C = (c, d) -> c + d;
//        System.out.println(a + " + " + b + " = " + C.compute(a, b));
//        C = (c, d) -> c - d;
//        System.out.println(a + " - " + b + " = " + C.compute(a, b));
//        C = (c, d) -> c * d;
//        System.out.println(a + " * " + b + " = " + C.compute(a, b));
//        C = (c, d) -> c / d;
//        System.out.println(a + " / " + b + " = " + C.compute(a, b));
        System.out.println(C.compute(a, b));

    }
}

@FunctionalInterface
interface Compute {
    double compute(double a, double b);
}